package dt_fs

import (
	"github.com/MzoroHaHa/dev-tools/backend/app/main-app/functions"
	"github.com/gin-gonic/gin"
	"log/slog"
)

type FileInfo struct {
	logger slog.Logger
}

func NewFileInfo(group *gin.RouterGroup) *FileInfo {
	r := &FileInfo{}
	group.GET("/select-file", r.SelectFile)
	r.logger = slog.Logger{}
	return r

}

func (n *FileInfo) SelectFile(c *gin.Context) {
	path, err := functions.SelectFile()
	if err != nil {
		c.JSON(200, gin.H{
			"code": 2,
			"msg":  err.Error(),
		})
		return
	}
	c.JSON(200, gin.H{
		"code": 1,
		"path": path,
	})
}
